// Source File Name:   InnerClass.java

package com.vhly.classfile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class InnerClass {

    private int inner_class_index;
    private int outer_class_index;
    private int inner_name_index;
    private int inner_access_flags;

    public InnerClass() {
        inner_class_index = 0;
        outer_class_index = 0;
        inner_name_index = 0;
        inner_access_flags = 0;
    }

    public InnerClass(int innerClassIndex, int outerClassIndex, int innerNameIndex, int accessFlags) {
        inner_class_index = innerClassIndex;
        outer_class_index = outerClassIndex;
        inner_name_index = innerNameIndex;
        inner_access_flags = accessFlags;
    }

    public InnerClass(InnerClass innerclass) {
        this(innerclass.getIC(), innerclass.getOC(), innerclass.getIName(), innerclass.getIAccess());
    }

    public int getIC() {
        return inner_class_index;
    }

    public int getOC() {
        return outer_class_index;
    }

    public int getIName() {
        return inner_name_index;
    }

    public int getIAccess() {
        return inner_access_flags;
    }

    public void setIC(int i) {
        inner_class_index = i;
    }

    public void setOC(int i) {
        outer_class_index = i;
    }

    public void setIName(int i) {
        inner_name_index = i;
    }

    public void setIAccess(int i) {
        inner_access_flags = i;
    }

    public void read(DataInputStream din)
            throws IOException {
        inner_class_index = din.readUnsignedShort();
        outer_class_index = din.readUnsignedShort();
        inner_name_index = din.readUnsignedShort();
        inner_access_flags = din.readUnsignedShort();
    }

    public void write(DataOutputStream dout)
            throws IOException {
        dout.writeShort(inner_class_index);
        dout.writeShort(outer_class_index);
        dout.writeShort(inner_name_index);
        dout.writeShort(inner_access_flags);
    }
}